<template>
  <div class="container">
    <el-row style="height: 100vh;width: 100%">
      <!--      区域树-->
      <el-col :span="4" class="left">
        <el-input placeholder="请输入关键字搜索..." clearable size="mini" suffix-icon="el-icon-search" v-model="filterText"></el-input>
        <div class="mt10">
          <el-tree
            ref="tree"
            :data="dataTreeList"
            :props="defaultProps"
            :filter-node-method="filterNode"
            :highlight-current="true"
            v-loading="treeLoading"
            :current-node-key="currentNodeKey"
            @node-click="handleNodeClick"
            :default-expand-all="true"
          >
          </el-tree>
        </div>
      </el-col>
      <el-col :span="20" class="right">
        <div class="right-card">
          <v-scale-screen ref="scale-screen" width="1980" height="1080" :fullScreen="true" style="background: black;width: 1370px;height: 730px;">
            <!--              <iframe id="iframeContainer" :src="projectUrl" frameborder="0" width="1380" height="800"/>-->
            <!--              <el-image ></el-image>-->
            <el-image
              style="width: 1415px; height: 870px"
              :src="require('@/assets/images/topology/dianli.jpg')"
              fit="fill"></el-image>
          </v-scale-screen>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
const topologyUrl = process.env.VUE_APP_TOPOLOGY_BASE_URL
export default {
  name: 'PowerDistributionRoom',
  data() {
    return {
      // 拓扑图标题
      title: '',
      // 区域树搜索框数据
      filterText: '',
      // 区域树数据
      dataTreeList: [{
        label: '雅达工业园',
        children: [{
          label: '01#电房',
        },{
          label: '02#电房',
        },{
          label: '03#电房',
        }]
      }],
      // 区域树配置
      defaultProps: {
        children: "children",
        label: "label"
      },
      // 当前选中的节点
      currentNodeKey: [],
      // 区域树加载状态
      treeLoading: false,
      // 地址
      baseURL: topologyUrl,
      // 项目ID
      projectId: null,
      gwsn: null,
    }
  },
  mounted() {
    const that = this
    this.$nextTick(() => {
      this.initIframe()
      window.addEventListener('resize', that.initIframe)
    })

  },
  watch: {
    filterText(val) {
      this.$refs.tree.filter(val)
    }
  },
  computed: {
    projectUrl() {
      // return this.baseURL + 'topologyPreview?project_id=' + this.projectId + '&gwsn=' + 'WG583OWAN24031102949'
      return 'http://127.0.0.1:8220/topologyPreview?project_id=' + 25
    }
  },
  methods: {
    // 点击区域树节点
    handleNodeClick(data) {
      this.title = data.label
    },
    // handleDataTimeUpdate(data) {
    //   const source = 'topology_' + this.gwsn + '_' + this.projectId
    //   if (source === data.source) {
    //     this.dataTime = moment(data.dataTime).format('YYYY-MM-DD HH:mm:ss')
    //   }
    // }
    onIframeLoad(){
      return this.$emit('iframe_loaded')
    },
  },

}
</script>
<style scoped lang="scss">
.container {
  width: 100%;
  height: 100vh;
  background: whitesmoke;
  .left{
    padding: 20px 10px 10px 10px;
    height: 100vh;
    background: #fff;
  }
  .right{
    padding: 10px 10px;
    height: 90vh;
    .right-card{
      height: 100%;
      width: 100%;
      box-shadow: 0 0 5px #ccc;
      border: 1px solid #DCDFE6;
      background: #fff;
      padding: 20px 20px;

    }
  }
}

</style>
